package com.kehutong.wwin.service.entity;

import java.util.List;

import org.coraframework.json.JSONObject;
import org.coraframework.orm.Entity;
import org.coraframework.orm.annotation.Column;
import org.coraframework.orm.annotation.Table;
import org.coraframework.orm.annotation.UnSave;
import org.coraframework.orm.util.IDType;

@Table(value="t_wwin_employee", multi=true, idType=IDType.TIMESTAMP)
public class EmployeeMap extends Entity {

	private static final long serialVersionUID = -2388890134470204495L;

	protected EmployeeMap(String id) {
		super(id);
	}
	@Column(comment="微信userId")
	private String userId;

	@Column(comment="客户通id")
	private String khtid;

	@Column(length=64, comment="用户名称")
	private String name;			//	成员名称

	@Column(length=255, comment="头像")
	private String avatar;			//	头像url。注：如果要获取小图将url最后的”/0”改成”/100”即可。


	@UnSave private Integer mainDepartment;	//	主部门
	@UnSave private List<Integer> departments;		//	成员部门列表，仅返回该应用有查看权限的部门id
	@UnSave private String mobile;			//	手机号码
	@UnSave private String gender;			//	性别，1表示男性，2表示女性
	@UnSave private String email;			//	邮箱
	@UnSave private String status;			//	激活状态：1=已激活 2=已禁用 4=未激活 已激活代表已激活企业微信或已关注微工作台（原企业号）5=成员退出
	@UnSave private String telephone;		//	座机
	@UnSave private String address;			//	地址
	@UnSave private String qrCode;			//	员工个人二维码

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getKhtid() {
		return khtid;
	}
	
	public void setKhtid(String khtid) {
		this.khtid = khtid;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public List<Integer> getDepartments() {
		return departments;
	}

	public void setDepartments(List<Integer> departments) {
		this.departments = departments;
	}

	public Integer getMainDepartment() {
		return mainDepartment;
	}
	
	public void setMainDepartment(Integer mainDepartment) {
		this.mainDepartment = mainDepartment;
	}
	
	public String getMobile() {
		return mobile;
	}
	
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	public String getGender() {
		return gender;
	}
	
	public void setGender(String gender) {
		this.gender = gender;
	}
	
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
	
	public String getStatus() {
		return status;
	}
	
	public void setStatus(String status) {
		this.status = status;
	}
	
	public String getAvatar() {
		return avatar;
	}
	
	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}
	
	public String getTelephone() {
		return telephone;
	}
	
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	
	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}

	public String getQrCode() {
		return qrCode;
	}

	public void setQrCode(String qrCode) {
		this.qrCode = qrCode;
	}

	public JSONObject toWwJson() {
		JSONObject wwJson = new JSONObject();

		wwJson.put("userid", this.id);
		wwJson.put("name", this.name);
		wwJson.put("mobile", this.mobile);
		wwJson.put("department", this.departments);
		wwJson.put("gender", this.gender);
		wwJson.put("email", this.email);
		wwJson.put("avatar_mediaid", this.avatar);
		wwJson.put("telephone", this.telephone);
		wwJson.put("address", this.address);
		wwJson.put("main_department", this.mainDepartment);
		wwJson.put("qr_code", this.qrCode);
		
		return wwJson;
	}
	
	public JSONObject toKhtJson() {
		JSONObject wwJson = new JSONObject();
		
		wwJson.put("id", this.khtid);
		wwJson.put("username", this.id);
		wwJson.put("name", this.name);
		wwJson.put("nickname", this.name);
		wwJson.put("avatar", this.avatar);
		wwJson.put("gender", this.gender);
		wwJson.put("mobile", this.mobile);
		wwJson.put("department", this.departments);
		wwJson.put("departments", this.mainDepartment);
		wwJson.put("email", this.email);
		wwJson.put("address", this.address);
		wwJson.put("qrCode", this.qrCode);

		return wwJson;
	}

}
